/**
 * Created by yuxinhai on 2016/12/15.
 */

require(["jv", "vue", "mui"], function () {
  var Vue = require("vue");

  if (!location.map.token) {
    jv.setToken();
  }


  var vm = jv.vm = new Vue({
    el: '#app',
    data: {name: "", mobile: "", address: "", company_name: "", fuwus: []},
    computed: {},
    methods: {
      listClick: function (ev) {
        $(ev.target).siblings("input").focus();
        $(ev.target).find("input:eq(0)").focus();
      },
      toList: function () {
        window.location = "/wuye/ayi/list";
      },
      saveClick: function () {
        var self = this;
        if (location.action == "add") {

          jv.post("/wuye/ayi/add", jv.vm.$data, function () {
            self.toList();
          });
        }
      },
      chkClick: function (item, ev) {
        item.value = $(ev.target).closest(".mui-switch").hasClass("mui-active");
      }
    }
  });


  // $(document.documentElement).addClass("loaded").css("animation", "loading 1s");

  jv.post("/wuye/ayi/fuwu_list", function (res) {
    jv.vm.$data.fuwus = res;

    vm.$nextTick(function () {
      $(".mui-switch").removeAttr("data-switch");
      mui('.mui-switch').switch();
    });

  });

  if (window.android && window.android.setTitle) {
    window.android.setTitle("添加阿姨");
    window.android.setExtName("");
  }
});
